package main

import (
	"fmt"
	"sync"
	"sync/atomic"
)

var a int32

// var b sync.Mutex

func main() {
	var wg sync.WaitGroup
	wg.Add(2)
	go func(wg *sync.WaitGroup) {
		var i int32
		defer wg.Done()

		for ; i < 10000; i++ {
			atomic.AddInt32(&a, 1)
			// b.Lock()
			// a += 1
			// b.Unlock()
		}
	}(&wg)
	go func(wg *sync.WaitGroup) {
		var i int32
		defer wg.Done()
		for ; i < 10000; i++ {
			atomic.AddInt32(&a, 1)
			// b.Lock()
			// a += 1
			// b.Unlock()

		}
	}(&wg)

	wg.Wait()
	fmt.Println(a)
}
